/**
 */
package entityrelationship.provider;

import entityrelationship.util.EntityrelationshipAdapterFactory;

import java.util.ArrayList;
import java.util.Collection;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;

import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;

/**
 * This is the factory that is used to provide the interfaces needed to support Viewers.
 * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
 * The adapters also support Eclipse property sheets.
 * Note that most of the adapters are shared among multiple instances.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class EntityrelationshipItemProviderAdapterFactory extends EntityrelationshipAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
	/**
	 * This keeps track of the root adapter factory that delegates to this adapter factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComposedAdapterFactory parentAdapterFactory;

	/**
	 * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IChangeNotifier changeNotifier = new ChangeNotifier();

	/**
	 * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Collection<Object> supportedTypes = new ArrayList<Object>();

	/**
	 * This constructs an instance.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EntityrelationshipItemProviderAdapterFactory() {
		supportedTypes.add(IEditingDomainItemProvider.class);
		supportedTypes.add(IStructuredItemContentProvider.class);
		supportedTypes.add(ITreeItemContentProvider.class);
		supportedTypes.add(IItemLabelProvider.class);
		supportedTypes.add(IItemPropertySource.class);
	}

	/**
	 * This keeps track of the one adapter used for all {@link entityrelationship.Entity} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EntityItemProvider entityItemProvider;

	/**
	 * This creates an adapter for a {@link entityrelationship.Entity}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createEntityAdapter() {
		if (entityItemProvider == null) {
			entityItemProvider = new EntityItemProvider(this);
		}

		return entityItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link entityrelationship.Attribute} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AttributeItemProvider attributeItemProvider;

	/**
	 * This creates an adapter for a {@link entityrelationship.Attribute}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createAttributeAdapter() {
		if (attributeItemProvider == null) {
			attributeItemProvider = new AttributeItemProvider(this);
		}

		return attributeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link entityrelationship.Relationship} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RelationshipItemProvider relationshipItemProvider;

	/**
	 * This creates an adapter for a {@link entityrelationship.Relationship}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createRelationshipAdapter() {
		if (relationshipItemProvider == null) {
			relationshipItemProvider = new RelationshipItemProvider(this);
		}

		return relationshipItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link entityrelationship.Entity_Relationship_Model} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Entity_Relationship_ModelItemProvider entity_Relationship_ModelItemProvider;

	/**
	 * This creates an adapter for a {@link entityrelationship.Entity_Relationship_Model}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createEntity_Relationship_ModelAdapter() {
		if (entity_Relationship_ModelItemProvider == null) {
			entity_Relationship_ModelItemProvider = new Entity_Relationship_ModelItemProvider(this);
		}

		return entity_Relationship_ModelItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link entityrelationship.Relationships_Restriction} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Relationships_RestrictionItemProvider relationships_RestrictionItemProvider;

	/**
	 * This creates an adapter for a {@link entityrelationship.Relationships_Restriction}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createRelationships_RestrictionAdapter() {
		if (relationships_RestrictionItemProvider == null) {
			relationships_RestrictionItemProvider = new Relationships_RestrictionItemProvider(this);
		}

		return relationships_RestrictionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link entityrelationship.Attribute_Composite} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Attribute_CompositeItemProvider attribute_CompositeItemProvider;

	/**
	 * This creates an adapter for a {@link entityrelationship.Attribute_Composite}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createAttribute_CompositeAdapter() {
		if (attribute_CompositeItemProvider == null) {
			attribute_CompositeItemProvider = new Attribute_CompositeItemProvider(this);
		}

		return attribute_CompositeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link entityrelationship.Connection_Entity_Relationship} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Connection_Entity_RelationshipItemProvider connection_Entity_RelationshipItemProvider;

	/**
	 * This creates an adapter for a {@link entityrelationship.Connection_Entity_Relationship}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createConnection_Entity_RelationshipAdapter() {
		if (connection_Entity_RelationshipItemProvider == null) {
			connection_Entity_RelationshipItemProvider = new Connection_Entity_RelationshipItemProvider(this);
		}

		return connection_Entity_RelationshipItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link entityrelationship.Connection_E_R_Restriction} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Connection_E_R_RestrictionItemProvider connection_E_R_RestrictionItemProvider;

	/**
	 * This creates an adapter for a {@link entityrelationship.Connection_E_R_Restriction}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createConnection_E_R_RestrictionAdapter() {
		if (connection_E_R_RestrictionItemProvider == null) {
			connection_E_R_RestrictionItemProvider = new Connection_E_R_RestrictionItemProvider(this);
		}

		return connection_E_R_RestrictionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link entityrelationship.Generalization} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected GeneralizationItemProvider generalizationItemProvider;

	/**
	 * This creates an adapter for a {@link entityrelationship.Generalization}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createGeneralizationAdapter() {
		if (generalizationItemProvider == null) {
			generalizationItemProvider = new GeneralizationItemProvider(this);
		}

		return generalizationItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link entityrelationship.Connection_With_Attribute} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Connection_With_AttributeItemProvider connection_With_AttributeItemProvider;

	/**
	 * This creates an adapter for a {@link entityrelationship.Connection_With_Attribute}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createConnection_With_AttributeAdapter() {
		if (connection_With_AttributeItemProvider == null) {
			connection_With_AttributeItemProvider = new Connection_With_AttributeItemProvider(this);
		}

		return connection_With_AttributeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link entityrelationship.Elements_with_Attributes} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Elements_with_AttributesItemProvider elements_with_AttributesItemProvider;

	/**
	 * This creates an adapter for a {@link entityrelationship.Elements_with_Attributes}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createElements_with_AttributesAdapter() {
		if (elements_with_AttributesItemProvider == null) {
			elements_with_AttributesItemProvider = new Elements_with_AttributesItemProvider(this);
		}

		return elements_with_AttributesItemProvider;
	}

	/**
	 * This returns the root adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ComposeableAdapterFactory getRootAdapterFactory() {
		return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
	}

	/**
	 * This sets the composed adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
		this.parentAdapterFactory = parentAdapterFactory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean isFactoryForType(Object type) {
		return supportedTypes.contains(type) || super.isFactoryForType(type);
	}

	/**
	 * This implementation substitutes the factory itself as the key for the adapter.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter adapt(Notifier notifier, Object type) {
		return super.adapt(notifier, this);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object adapt(Object object, Object type) {
		if (isFactoryForType(type)) {
			Object adapter = super.adapt(object, type);
			if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) {
				return adapter;
			}
		}

		return null;
	}

	/**
	 * This adds a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void addListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.addListener(notifyChangedListener);
	}

	/**
	 * This removes a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void removeListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.removeListener(notifyChangedListener);
	}

	/**
	 * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void fireNotifyChanged(Notification notification) {
		changeNotifier.fireNotifyChanged(notification);

		if (parentAdapterFactory != null) {
			parentAdapterFactory.fireNotifyChanged(notification);
		}
	}

	/**
	 * This disposes all of the item providers created by this factory. 
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void dispose() {
		if (entityItemProvider != null) entityItemProvider.dispose();
		if (attributeItemProvider != null) attributeItemProvider.dispose();
		if (relationshipItemProvider != null) relationshipItemProvider.dispose();
		if (entity_Relationship_ModelItemProvider != null) entity_Relationship_ModelItemProvider.dispose();
		if (relationships_RestrictionItemProvider != null) relationships_RestrictionItemProvider.dispose();
		if (attribute_CompositeItemProvider != null) attribute_CompositeItemProvider.dispose();
		if (connection_Entity_RelationshipItemProvider != null) connection_Entity_RelationshipItemProvider.dispose();
		if (connection_E_R_RestrictionItemProvider != null) connection_E_R_RestrictionItemProvider.dispose();
		if (generalizationItemProvider != null) generalizationItemProvider.dispose();
		if (connection_With_AttributeItemProvider != null) connection_With_AttributeItemProvider.dispose();
		if (elements_with_AttributesItemProvider != null) elements_with_AttributesItemProvider.dispose();
	}

}
